package com.anysoft.adapter;

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.anysoft.R;

import java.util.List;

/**
 * 开户银行选择列表适配器
 * Created by yanbin on 2016-08-01.
 */
public class BankSelectAdapter extends BaseAdapter {

        private Context context;

    private List<String> listBank;

    /**
     * 好友展现列表适配器
     *
     * @param context            上下问
     */
    public BankSelectAdapter(Activity context, List<String> listBank) {
        this.context = context;
        this.listBank = listBank;
    }


    @Override
    public int getCount() {
        if (listBank == null)
            return 0;
        return listBank.size();
    }

    @Override
    public Object getItem(int position) {
        return listBank.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        final ViewHolder holder;
        if (convertView == null) {
            convertView = View.inflate(context, R.layout.list_item_bank, null);
            holder = new ViewHolder();
            holder.tvBankName = (TextView) convertView.findViewById(R.id.tvBankName);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.tvBankName.setText(listBank.get(position));
        return convertView;
    }


    public static class ViewHolder {
        /**
         * 姓名
         */
        TextView tvBankName;
    }

}
